#!/bin/bash

# openssl genrsa -out server.key 2048
# openssl req -new -key server.key -out server.csr
# openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

# 设置证书相关信息
SUBJECT='/C=US/ST=CA/L=San Francisco/O=example.com/CN=localhost'
VALIDITY_DAYS=3650

# 创建证书目录
mkdir -p certs

cd certs || exit

openssl genrsa -out server.key 2048
openssl req -new -key server.key -out server.csr -subj "$SUBJECT"
openssl x509 -req -days "$VALIDITY_DAYS" -in server.csr -signkey server.key -out server.crt

echo 'Certificate generation successful. Certs files are in the "certs" directory.'